import axios from 'axios'

const instance = axios.create({
  baseURL: 'http://baidu.com',
  timeout: 3000
})
instance.interceptors.request.use(
  config => {
    return config
  },
  error => {
    return Promise.reject(error)
  })

// Add a response interceptor
instance.interceptors.response.use(
  response => {
    // Any status code that lie within the range of 2xx cause this function to trigger
    // Do something with response data
    return response
  },
  error => {
    // Any status codes that falls outside the range of 2xx cause this function to trigger
    // Do something with response error
    return Promise.reject(error)
  }
)
